import { showToast, showDialog, showConfirmDialog } from 'vant'
import 'vant/es/dialog/style'
import 'vant/es/toast/style' 
import "/@/assets/css/message.less"
import { policyListStore } from "/@/stores/policyListStore"
const pStore = policyListStore()
interface messageParams {
    title?: string,
    message:string,
    confirmText?:string

}

export function Dialog(params:messageParams):Promise<void> {
    return new Promise((resolve,reject) => {
        showDialog({
            title: params.title || "温馨提示",
            message: params.message, // '您的手机号已被占用注册，请更换手机号。'
            theme: 'round-button',
            confirmButtonText:params.confirmText || "好的",
            className:"authDialog"
        }).then(() => {
            resolve()
        })
            .catch((error) => {
                reject(error)
            })
    })
}
export function Toast(str:string) {
    showToast(str) 
}

export function confirmDialog(router:any):any {
    const orouter = router
    showConfirmDialog ({
        title: "温馨提示",
        message: "您确认要退出本次服务吗？",
        className:"closeDialog",
        confirmButtonText:"取消",
        cancelButtonText:"继续退出"
    }).then(() => {
        // on confirm
        console.log(1)
    })
    .catch(() => {
        const isJstLogin = sessionStorage.getItem('jstJointLoginVo')
        if(isJstLogin){
            //  适用于金世通嵌套
			router.replace({ path: '/jstTask',query: { type: 1 }})
        } else {
            //     window.location.href = pStore.reviewTipsUri
            orouter.push({
                path: '/reportingResultwxts',
            })
        }
    })
}